#include <stdio.h>
#include<func.h>
int printdir(char* argv,int width)
{
    DIR* dir;
    dir=opendir(argv);
    ERROR_CHECK(dir,NULL,"opendir")
    struct dirent *p;
    char buf[1024]={0};
    while(p=readdir(dir))
    {
        if(!strcmp(p->d_name,".")||!strcmp(p->d_name,".."))
        {
            continue;
        }
        else
        printf("%*s%s\n",width,"",p->d_name);
        if(p->d_type==4)
        {   memset(buf,0,sizeof(buf));
            sprintf(buf,"%s%s%s",argv,"/",p->d_name);
            printdir(buf,width+4);
        }
    }
    closedir(dir);
    return 0;
}
int main(int argc,char* argv[])
{
    ARGS_CHECK(argc,2)
    printdir(argv[1],0);
    return 0;
}

